<script>
$(function(){
    $('td[edit]').dblclick(function(){
        var val = $(this).html();
        var field = $(this).attr('field');
        var wparam = $(this).parents().attr('wparam');
        var uuid = AUKEY+field+wparam;
        $(this).html("<input id='"+uuid+"' style='width:auto;' value='"+val+"' />");
        $('#'+uuid).focus().live('blur',function(){
            var now_val = $(this).val();
            $(this).parents('td').html(now_val);
            $.getJSON('?app=<?php echo APP; ?>&mod=modi',{type:'fast',field:field,value:now_val,wparam:wparam});
        });
    });
    // 删除
    $('img[del]').click(function (){
        var uid = $(this).attr('del');
        var nickname = $(this).attr('nickname');

        if(confirm('真的要删除'+nickname+'吗？')) {
            $.getJSON('?app=<?php echo APP; ?>&mod=delete',{uid:uid},function(data){
                if (data.state <= 0)
                {
                    alert(data.message);
                    return false;
                }
                $('tr[wparam='+uid+']').remove();
            });
        }
    });
    // 修改可见状态
    $('img[yesno]').click(function(){
        if (confirm('真的要更改该账号状态吗？'))
        {
            var obj = $(this);
            $.getJSON('?app=<?php echo APP; ?>&mod=modi',{type:'activity',uid:$(this).attr('yesno')},function(data){
                if (data.state <= 0)
                {
                    alert(data.message);
                    return false;
                }
                if (data.extra != '')
                {
                    obj.attr('src',data.extra);
                }
            });
        }
    });
    // 重置密码
    $('img[resetpassword]').click(function(){
        if (confirm('真的要重置该帐号密码吗？'))
        {
            $.post('?app=<?php echo APP; ?>&mod=modi',{type:'resetpassword',uid:$(this).attr('resetpassword')},function data(data){
                if (data.state <= 0)
                {
                    alert(data.message);
                    return false;
                }
                alert('密码已经重置为'+data.extra+'请登陆后修改密码！');
            },'json');
        }        
    });
});
</script>
<div class="line_1"></div>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="table1">
       <tr>
            <th class="th0">编号</th>
            <th class="th1">用户名</th>
            <th class="th1">姓名</th>
            <th class="th1">最后登录时间</th>
            <th class="th1">最后登录IP</th>
            <th class="th0">登录次数</th>
            <th class="th0">是否可用</th>
            <th class="th1">操作</a>
       </tr>
       <?php foreach($this->members as $member): ?> 
       <tr wparam='<?php echo $member['uid']; ?>'>
            <td><?php echo $member['uid']; ?></td>
            <!--<td edit field='username'><?php echo $member['username']; ?></td>
            <td edit field='nickname'><?php echo $member['nickname']; ?></td>-->
            <td><?php echo $member['username']; ?></td>
            <td><?php echo $member['nickname']; ?></td>
            <td><?php echo $member['last_login_time'] ? date('Y-m-d H:i:s',$member['last_login_time']) : '-'; ?></td>
            <td><?php echo long2ip($member['last_login_ip']); ?></td>
            <td><?php echo $member['login_sum']; ?></td>
            <td><?php echo yesno($member['activity'],"yesno='{$member['uid']}'"); ?></td>
            <td><?php echo opt('trash','javascript:;','del="'.$member['uid'].'" nickname="'.$member['nickname'].'"').opt('edit','javascript:;',"resetpassword='".$member['uid']."' title='重置密码'").opt('edit','?app=manager&mod=perm&uid='.$member['uid'],'title="修改权限"').'&nbsp;'.opt('edit','?app=manager&mod=modi&uid='.$member['uid'],'title="管理员信息修改"'); ?>
            </td>
       </tr>
       <?php endforeach; ?>
</table>
<div class="page_num">
     <div class="fl">
        <span>提示：双击编辑，鼠标点击页面其他处提交修改</span>
     </div>
     <div class="fr">
        <p class="cpager">
            <?php echo $this->pager; ?>
        </p>
     </div>
</div>